package com.dsw.idezjet.model;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

@Stateless
public class VoosEJB implements InterfaceVoos {

	@PersistenceContext
	EntityManager em;
	
	@Override
	public void adicionarVoo(Voo v) {
		em.persist(v);
		
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Voo> obterVoos() {
		javax.persistence.Query query = em.createQuery("Select v from Voo v");
		return query.getResultList();
	}

	@Override
	public void removerVoo(Voo v) {
		Voo aRemover = em.find(Voo.class, v.getId());
		em.remove(aRemover);
		
	}

	@Override
	public void editarVoo(Voo v) {
		em.merge(v);
		
	}

}
